package com.demo.controller.common;

import com.demo.util.ConfigLoader;
import com.demo.util.ControllerManager;
import com.demo.util.EmailSender;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;

import java.net.URL;
import java.util.ResourceBundle;

public class FooterController implements Initializable {
    @FXML
    private Label leftStatus;
    @FXML
    private Label rightStatus;

    public void refreshStatus() {
        StringBuilder sb = new StringBuilder();
        sb.append("当前用户：").append(ConfigLoader.getProperty("mail.smtp.username")).append("\t")
                .append("服务器：").append(ConfigLoader.getProperty("mail.smtp.host"));
        leftStatus.setText(sb.toString());
        if (EmailSender.isSessionConnected()) {
            rightStatus.setText("已连接");
        } else {
            rightStatus.setText("未连接");
        }
    }

    @Override
    public void initialize(URL url, ResourceBundle resourceBundle) {
        refreshStatus();
        ControllerManager.footerController = this;
    }

}
